#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

#define REP(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define PER(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

void solve(int a[], int n) {
    queue<int> Q;
    for (int i = 0; i < n; i++) {
        Q.push(a[i]);
    }
    while (!Q.empty()) {
        cout << Q.front() << " ";
        Q.pop();
        if (Q.size() > 1) {
            int x = Q.front();
            Q.pop();
            Q.push(x);
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a[] = {1, 2, 3, 4, 5};
    int n = sizeof(a) / sizeof(int);
    solve(a, n);

    return 0;
}
